package cglib;

import net.sf.cglib.proxy.Enhancer;

public class CglibTest
{
    public static void main(String[] args)
    {
        Enhancer enhancer = new Enhancer();
        //这里是要代理的类
        enhancer.setSuperclass(TargetObject.class);
        //这里是设置拦截器
        enhancer.setCallback(new TargetInterceptor());
        TargetObject targetObject2 = (TargetObject) enhancer.create();
        System.out.println(targetObject2);
        System.out.println(targetObject2.method1("mmm1"));
        System.out.println(targetObject2.method2(100));
        System.out.println(targetObject2.method3(2000));
    }
}
